home *** CD-ROM | disk | FTP | other *** search
- Path: vivid.autometric.com!usenet
- From: Joe Shelby <jshelby@autometric.com>
- Newsgroups: comp.lang.c++
- Subject: enumerated types and the new c++ standard...
- Date: Thu, 07 Mar 1996 11:28:48 -0500
- Organization: Vision International, a division of Autometric, Inc.
- Message-ID: <313F0EC0.2781@autometric.com>
- NNTP-Posting-Host: vivid.autometric.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; IRIX 5.3 IP22)
-
- enumerated types and the new c++ standard...
-
- it seems as though the C++ standards body has created something
- of a contradiction...
-
- they (for some odd reason) declared that enumerated types
- are no longer "integral", meaning for something like
-
- enum Wday { SUN = 0, MON, TUE, WED, THU, FRI, SAT } wday;
-
- the line:
-
- for (wday = SUN; w <= SAT; w++) {;}
-
- is no longer legal C++ (even though it is legal C). (and gcc 2.7.2
- respects this change and won't allow the code); the key problem
- is that <= and ++ are no longer defined for enumerated types...
-
- yet at the same time, i've not read anything that states that
- enum's can't be used as array indexes (meaning they inheritantly
- MUST be integral); and i've used them as array indexes
- with no warnings or problems whatsoever.
-
- why did the standards body choose the change? it seems that we
- now have to go back to the dreaded "#define" approach in order
- to get the desired code style... OR i can go about implementing
- a <= and a ++ operator, which can get VERY inefficient with
- "switch/case" statements and all that...
-
- joe
-
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Joseph Shelby : Software Engineer jshelby@autometric.com
- 5301 Shawnee Rd. Alexandria, VA 22312-2333 (703) 658-4071
- http://www.io.com/~acroyear
- I'm not sure who he is, but I've heard he's got his hand in a lot of things.
- --Kermit, about Jim Henson
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-